home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / foomatic / parseconfig.pl
Encoding:
Perl Script  |  2007-03-27  |  1.5 KB  |  57 lines

  1. #!/usr/bin/perl
  2.  
  3. my $configpath = "/etc/foomatic";
  4.  
  5. sub readConfFile
  6. {
  7.     my ($file) = @_;
  8.  
  9.     my %conf;
  10.     # Read config file if present
  11.     if (open CONF, "< $file")
  12.     {
  13.         while (<CONF>)
  14.         {
  15.             $conf{$1}="$2" if (m/^\s*([^\#\s]\S*)\s*:\s*(.*)\s*$/);
  16.         }
  17.         close CONF;
  18.     }
  19.  
  20.     return %conf;
  21. }
  22.  
  23. %conf = readConfFile("$configpath/filter.conf");
  24. print( 'db_set foomatic-filters/filter_debug ',
  25.        $conf{debug} > 0 ? 'true' : 'false', ";\n") if exists $conf{debug};
  26. if (exists $conf{gspath})
  27. {
  28.     if ($conf{gspath} =~ m/^(gs|gs-esp|gs-afpl|gs-gpl)$/) {
  29.         print "db_set foomatic-filters/gspath $1;\n";
  30.     } elsif ($conf{gspath} =~ m/^(gs-gnu|gs-aladdin)$/) {
  31.         # Force reconfiguration if still using gs-gnu or gs-aladdin
  32.         print "";
  33.     } else {
  34.         print "db_set foomatic-filters/gspath Custom;\n";
  35.         print "db_set foomatic-filters/custom_gspath $conf{gspath};\n";
  36.     }
  37. }
  38. if (exists $conf{textfilter})
  39. {
  40.     if ($conf{textfilter} =~ m/^(a2ps|enscript|mpage)$/)
  41.     {
  42.         print "db_set foomatic-filters/textfilter $1;\n";
  43.     }
  44.     elsif ($conf{textfilter} =~ m/^\s*$/)
  45.     {
  46.         print "db_set foomatic-filters/textfilter Automagic;\n";
  47.     }
  48.     else
  49.     {
  50.         print "db_set foomatic-filters/textfilter Custom;\n";
  51.         print "db_set foomatic-filters/custom_textfilter $conf{textfilter};\n";
  52.     }
  53. }
  54. print( 'db_set foomatic-filters/ps_accounting ',
  55.        $conf{ps_accounting} ? 'true' : 'false',
  56.        "\n") if exists $conf{ps_accounting};
  57.